<?
include("/var/www/html/new/com.inc.php");
$ordid=$ordern?$ordern:$_REQUEST['ordid'];
/*setcookie('ordid', $ordern);
setcookie('qrimg', $qrimg);
setcookie('uri', "http://16u.cc".$uri);*/
if(!$ordid){
	echo "<script>alert('无订单号!');</script>";
	exit;
}
$ac3=$GLOBALS['_ac'];
$pw3=$GLOBALS['_pw'];
function Make_Qrcode($Tcode){
	$rs=rand(0,6);
	$Tcode1=substr($Tcode,0,$rs);
	$Tcode2=substr($Tcode,$rs,(6-$rs));
	$rs1=rand(0,9);
	return $Tcode1.$rs1.$Tcode2.$rs;
}

$s3 = new SoapClient(null,array("location" => "http://localhost/open/openService/pft_insideMX.php","uri" => "www.16u.com?ac_16u=$ac3|pw_16u=$pw3|auth_16u=true"));
$xml=$s3->Order_Globle_Search(0,0,0,0,"","","","","","","","",$ordid,"",0,"","","",1,0,0,1);
if(is_numeric($xml)){
	echo "<script>alert('错误".$xml."');</script>";
	exit;
}
else{
	$arr=simplexml_load_string($xml);
	if($arr->Rec[0]->UUlid==-1){
		$isL=true;
		$xml=$s3->Order_Route_Search("","","","","","","","","","",$ordid,"","","","","","","",0,1,0);
		if(!is_numeric($xml)){
			$arr=simplexml_load_string($xml);
			switch($arr->Rec[0]->UUrtype){
				case 0:	$rtype="跟团游";break;
				case 1:	$rtype="自助游";break;
				case 2:	$rtype="当地游";break;
			}
		}
		elseif($xml!=105){
			echo $xml;
		}
	}
	switch((string)$arr->Rec[0]->UUpaystatus){
		case "0": $zt="未支付";break;
		case "1": $zt="已支付";break;
		case "2": $zt="未支付";break;
	}
//	if((string)$arr->Rec[0]->UUpayinfo=="9")$zt="已支付";
	switch((string)$arr->Rec[0]->UUstatus){
		case "0": $zt.="(未使用)";break;
		case "1": $zt.="(已使用)";break;
		case "2": $zt="已过期";break;
		case "3": $zt="已取消";break;
	}
	if(!$arr->Rec[0]->UUlid){exit("获取产品ID失败!");}
	$sel=$isL?"select buy_notes jqts,tour_notes from uu_route where pid = ".$arr->Rec[0]->UUpid:"select jqts from uu_land where id = ".$arr->Rec[0]->UUlid;
	$GLOBALS['le']->query($sel);
	$GLOBALS['le']->fetch_assoc();
	$jqts=$GLOBALS['le']->f("jqts");
}
$qrimg=file_get_contents("http://open.16u.com/qr?".Make_Qrcode($arr->Rec[0]->UUcode));
?>
<!doctype html>
<html>
<head>
<meta charset="gb2312">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;">
<title>电子凭证</title>
    <style>
        html{FONT-SIZE:100%;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;text-size-adjust:100%;background:#FFF}body{font-family:"微软雅黑","黑体","宋体";COLOR:#333}button,input,select,textarea{font-family:SimHei,"Microsoft YaHei";COLOR:#333}button,input[type="button"],input[type="reset"],input[type="submit"],[role="button"]{-webkit-appearance:button}input[type="radio"],input[type="checkbox"]{vertical-align:-2px}body,div,p,span,table,textarea,form,input,img,ul,li,h1,h2,h3,h4,h5,dl,dt,dd{margin:0;padding:0}img,a img,input,select,option{border:0}a{color:#333;text-decoration:none}a:hover{text-decoration:none;outline:0}body{font-size:14px;line-height:1.5;background-color:#fff;color:#333}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal}ul,ol,li{list-style:none}em,i{font-style:normal}input,img{vertical-align:middle}table{border-collapse:collapse;border-spacing:0}.head{width:100%;height:48px;background:url(http://www.12301.cc/p/mobile/images/head_bg.png) repeat-x;text-align:center;overflow:hidden}.head h1{color:#FFF;font-size:20px;line-height:48px;font-weight:bolder}.title{width:100%;height:22px;background:url(http://www.12301.cc/p/mobile/images/title_bg.png) repeat-x;overflow:hidden}.title_text{padding:0 0 0 3%;float:left;width:30%}.title_text h2{font-size:15px;font-weight:bolder;color:#FFF}.title_but{padding:0 3% 0 0;float:right;width:50%}.title_but li{background:url(http://www.16u.com/p/mobile/images/title_but.png) no-repeat;float:right;height:18px;width:60px;overflow:hidden;line-height:18px;text-align:center;margin:2px 0 0 6px}.title_but a{font-size:12px;color:#284d70}.dingdan{padding:10px;font-size:12px;color:#999}.dingdan table{border:1px solid #CCC}.dingdan table td{height:25px;padding:0 5px}.dingdan .line{border-bottom:1px solid #CCC}.dingdan span{color:#274c70}.erwei{text-align:center;padding:5px 0 15px;color:#284c70;font-weight:bold}.erwei img{margin:0 20px}.wenzi{padding:10px;font-size:15px}.wenzi p{text-indent:24px}#qrcode img{margin:0 auto;}
    </style>
</head>
<body>
<!--头部开始-->
<header>
  <section class="head"><h1><?=($isL?$arr->Rec[0]->UUtitle:$arr->Rec[0]->UUltitle)?></h1></section>
</header>
<!--头部结束-->
<!--<section class="erwei">对准窗口--><?//=$qrimg?><!--刷码验证</section>-->
<section class="erwei" style="width: 100%;">对准窗口<div id="qrcode"></div>刷码验证</section>
<!--订单信息开始-->
<section class="title">
	<section class="title_text"><h2>订单信息</h2></section>
    <section class="title_but">
    	<!--<ul>
	<?if((string)$arr->Rec[0]->UUfromt!="16ucom"){?><a href="http://www.12301.cc/p/mobile/xgdd.html?ordid=<?=$ordid?>&u=<?=urlencode($uri)?>"><li>修改订单</li></a><?}?>
        </ul>-->
    </section>
</section>
<article class="dingdan">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td class="line" align="center" bgcolor="#EFF1F4"><span>订单号</span></td>
        <td class="line"><?=$arr->Rec[0]->UUordernum?></td>
        <td class="line" align="center" bgcolor="#EFF1F4"><span>状&nbsp;&nbsp;&nbsp;态</span></td>
        <td class="line"><?=$zt?></td>
      </tr>
      <tr>
        <td class="line" align="center" bgcolor="#EFF1F4"><span><?=($isL?"线路类型":"票&nbsp;&nbsp;&nbsp;类")?></span></td>
        <td class="line"><?=($isL?$rtype:$arr->Rec[0]->UUttitle)?></td>
        <td class="line" align="center" bgcolor="#EFF1F4"><span>数&nbsp;&nbsp;&nbsp;量</span></td>
        <td class="line"><?=$arr->Rec[0]->UUtnum?></td>
      </tr>
      <tr>
        <td class="line" align="center" bgcolor="#EFF1F4"><span>联系人</span></td>
        <td class="line"><?=$arr->Rec[0]->UUordername?></td>
        <td class="line" align="center" bgcolor="#EFF1F4"><span>手&nbsp;&nbsp;&nbsp;机</span></td>
        <td class="line"><?=$arr->Rec[0]->UUordertel?></td>
      </tr>
      <tr>
        <td align="center" bgcolor="#EFF1F4" ><span>有效期</span></td>
        <td colspan="3"><?=$arr->Rec[0]->UUbegintime?> -- <?=$arr->Rec[0]->UUendtime?></td>
      </tr>
    <?php if($arr->Rec[0]->UUlid==10253):?>
        <?php $json = json_decode($arr->Rec[0]->UUseries, true);?>
        <!--轮渡产品-->
        <tr>
            <td align="center" style="border-top:1px solid #CCC; background-color: #EFF1F4" ><span>开船时间</span></td>
            <td colspan="3" style="border-top:1px solid #CCC;">
                <?=$json[1]?>
            </td>
        </tr>
    <?php endif;?>
    </table>
<?	$sel="select orderid from uu_order_fx_details where concat_id='".$ordid."'";
	$GLOBALS['le']->query($sel);
	while($row=$GLOBALS['le']->fetch_assoc()){
		$other=$s3->Order_Globle_Search(0,0,0,0,"","","","","","","","",$row['orderid']);
		if(is_numeric($other)){
			echo "<script>alert('错误".$other."');</script>";
			exit;
		}
		else{
			$other=simplexml_load_string($other);?>
    <table width="100%" border="0" cellspacing="0" cellpadding="0" style="margin-top:10px;">
      <tr>
        <td class="line" align="center" bgcolor="#EFF1F4"><span>订单号</span></td>
        <td class="line"><?=$other->Rec[0]->UUordernum?></td>
        <td class="line" align="center" bgcolor="#EFF1F4"><span>状&nbsp;&nbsp;&nbsp;态</span></td>
        <td class="line"><?=$zt?></td>
      </tr>
      <tr>
        <td class="line" align="center" bgcolor="#EFF1F4"><span><?=($isL?"线路类型":"票&nbsp;&nbsp;&nbsp;类")?></span></td>
        <td class="line"><?=($isL?$rtype:$other->Rec[0]->UUttitle)?></td>
        <td class="line" align="center" bgcolor="#EFF1F4"><span>数&nbsp;&nbsp;&nbsp;量</span></td>
        <td class="line"><?=$other->Rec[0]->UUtnum?></td>
      </tr>
    </table>
	<?	}
	}?>
</article>
<!--订单信息结束-->

<!--取票地点开始-->
<section class="title">
	<section class="title_text"><h2><?=($isL?"出行须知":"取票地点")?></h2></section>
</section>
<article class="wenzi">
	<p><?=($isL?$GLOBALS['le']->f("tour_notes"):$arr->Rec[0]->UUgetaddr)?></p>
</article>
<!--取票地点结束-->
<script src="http://wx.12301.cc/public/js/plugins/qrcode.min.js"></script>
<script>
    var qrcode = new QRCode("qrcode", {
        text: '<?=$arr->Rec[0]->UUcode?>',
        width: 128,
        height: 128,
        colorDark : "#000000",
        colorLight : "#ffffff",
        correctLevel : QRCode.CorrectLevel.H
    });
</script>
<?php
$GLOBALS['le']->close();
$request = array(
    'action'   => 'incHit',
    'name'     => '短信电子凭证页',    //页面名称
    'identify' => "dzpz", //页面标识
    'type'     => 2,    //页面类型(0平台内页面1帮助文档2微信分享页)
    'auth'     => md5('RFGrfgY5CjVP8LcYincHit')     //加密字符串,md5(api_key . 'incHit')
);
?>
<script src="http://121.41.120.34/pft/api/hits.php?data=<?=base64_encode(json_encode($request))?>"></script>
</body>
</html>